/*
 * @Descripttion:
 * @Author: machao
 * @Date: 2020-3-10 11:47:09
 * @LastEditors: machao
 * @LastEditTime: 2019-11-14 11:10:30
 */
export default class AnimationCtrl {
  private static _inst: AnimationCtrl;

  public static get inst(): AnimationCtrl {
    if (!this._inst) {
      this._inst = new AnimationCtrl();
    }
    return this._inst;
  }

  /**
   * 适用于 播放一次一个动画之后 一直播放一个循环动画
   * @param spNode
   * @param playAnimation
   * @param doneAnimation
   */
  public playAnimationOnce(spNode: sp.Skeleton, playAnimation: string, doneAnimation: string): void {
    spNode.setAnimation(0, playAnimation, false);
    spNode.setCompleteListener(() => {
      spNode.setCompleteListener(null);
      spNode.setAnimation(0, doneAnimation, true);
    });
  }
}
